<?php 
	$modelProduct = new Model_Product_Product();
?>
<div class="box"> <!-- Box begins here -->
	<h2>Danh sách hình ảnh <?php echo $modelProduct->getNamebyId($this->product);?></h2>
	<table>
	<thead>
		<tr>
			<td>Id </td>
			<td>Hình ảnh</td>
			<td>Thao tác</td>
		</tr>
	</thead>
	<tbody>
		<?php
				if(!empty($this->data)): 
			?>
			<?php foreach($this->data as $item): ?>
			<tr class="">
				<td><?php echo $item['id']; ?></td>
				<td><img src="<?php echo $this->baseUrl().PRODUCT_URL.'/thumbs/'.$item['filename']; ?>" alt="" /></td>
				<td>
					<a class="delete" href="<?php echo $this->url(array("module"=>"administrator","controller"=>"product","action"=>"imagedel","id"=>$item['id']),null,true);?>">Xóa</a>
				</td>
			</tr>
		     <?php endforeach; ?>
		     <?php else :?>
			 <tr>
			 	<td colspan=3>
			 	Không có file nào.
				</td>
			 </tr>
			 <?php endif; ?>
	</tbody>
	</table>
	<form method="post" action="" enctype="multipart/form-data"><!-- Form -->
		<fieldset><legend>Upload Hình Ảnh</legend>
			<div class="input_field">
				<label for="image">Hình ảnh</label>
		 		<?php echo  $this->formFile("image",array("size"=>55));?>
		 		<?php if(!empty($this->error['image'])): ?>
		 			<span class="validate_error"><?php echo $this->error['image']; ?></span>
		 		<?php endif; ?>
			</div>
		</fieldset>
		<input class="submit" type="submit" value="Thực hiện" />
	</form>
</div>
<script type="text/javascript">
	$(document).ready(function(){
			$(".delete").click(function(){
				if(confirm("Ban mua xoa ?")){
					$(this).parent().parent().remove();
					$.get($(this).attr("href"));
				}
				return false;
			});
	});
</script>
	